pragma runLim, 0 #include // Environment variable const string USER_PROFILE = getenv((NLS_("USERPROFILE"))) // Desktop variable const string fName = USER_PROFILE (NLS_("\\Desktop\\Error.log")) string results = null if (fileExists_(fName)) { results = deleteFile(fName) if (!null results) { errorBox(results) halt } } // Timer variables. int TimeStart, TimeEnd string timer(int milliseconds) { int seconds = (int ((milliseconds / 1000) % 60)) int minutes = (int ((milliseconds / (1000*60)) % 60)) int hours = (int ((milliseconds / (1000*60*60)) % 24)) return((NLS_("Total run-time('")) hours (NLS_(":")) minutes (NLS_(".")) seconds (NLS_("')"))) } // timer ///-------------------------------------------------------------------------------------- //https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14830975#14830975 const bool DEBUG_Alloc = false int *::+(int *ptr1, int ofs) { int *ptr2 = ptr1; ptr2+=ofs; return(ptr2) } int *::@(int *ptr, int ofs) { int ad = *(ptr + ofs); int *ptr2 = addr_ ad; return(ptr2) } int *ccp () { DB x = create "" int *p = addr_ x; int *r = p @ 48 destroy x return(r) } int *mbn (int *cc) { return(cc @ 0x74) } int *dp (int *n) { return(n @ 0) } int *nn (int *n) { return(n @ 8) } int allocatedObjects() { int cnt = 0 int *mb = mbn ccp() while (!null mb) { mb = nn mb; cnt++ } return(cnt) } ///-------------------------------------------------------------------------------------- void LogFile(string msg) { string err = null noError() Stream logBuf = append(fName) logBuf << msg logBuf << (NLS_("\n")) close(logBuf) // Close log file. err = lastError() if (!null err) LogFile(fName (NLS_(" [")) err (NLS_("]"))) } // LogFile /******************************************************************************* * PrintAllocs * */ void PrintAllocs(string Label) { if (DEBUG_Alloc) then print (Label (NLS_("\t")) allocatedObjects() (NLS_("\n"))) }//End PrintAllocs ///---------------------------------------------------------------------------------- PrintAllocs((NLS_("Allocated Objects at Start(Script) of DXL code:"))) ///---------------------------------------------------------------------------------- ///---------------------------------------------------------------------------------- PrintAllocs((NLS_("Allocated Objects at Start(Initialization) of DXL code:"))) ///---------------------------------------------------------------------------------- DB LinkDB = null, editDB = null DBE sourceMod DBE frame1, frame2 DBE selectTargetMods, selectedTargetMods, targetModField, linkModField DBE linkSrcAttributeList, linkTgtAttributeList, directionRadioBox DBE okButton, rmButton Skip linkSrcAttributeSkip = create Skip linkTgtAttributeSkip = createString const string linkLinkSrcToTrg = (NLS_("Source to target")) const string linkLinkTrgToSrc = (NLS_("Target to source")) const string linkLinkBothWays = (NLS_("Both directions")) const string direction[] = {LS_("String_Source_to_target", NLSTEMP_("Source to target")), LS_("String_Target_to_source", NLSTEMP_("Target to source")), LS_("String_Both_directions", NLSTEMP_("Both directions"))} Module linkSrcMod = null string items [] = {} string dummy_list[] = {} int numItems = 0 bool AddItemTrc = false int glbsel = 0 bool glbprogressCancelled = true ///---------------------------------------------------------------------------------- PrintAllocs((NLS_("Allocated Objects at End(Initialization) of DXL code:"))) ///---------------------------------------------------------------------------------- /******************************************************************************* * insertAlphabetically_ * */ void insertAlphabetically_(DBE listDBE, int i, string mod) { string s = null int j = 0 bool db_showing = showing parentOf listDBE if (i < 0) return else if (i == 0 && db_showing) insert(listDBE, 0, mod) else { j = 0 while (j < i) { s = get(listDBE, j) if (lower mod > lower s) j++ else if (db_showing) { insert(listDBE, j, mod) j = i + 1 } } if (j == i && db_showing) insert(listDBE, j, mod) } }//End insertAlphabetically_ /******************************************************************************* * linkRefreshSrcAttributeList * */ void linkRefreshSrcAttributeList(Module& m) { string attr = null AttrDef ad = null int i = 0 int old_pos = get linkSrcAttributeList for attr in m do { if (null attr) continue ad = find(m, attr) if (ad.object) { if ((ad.typeName == (NLS_("Text"))) or (ad.typeName == (NLS_("String"))) or (ad.typeName == (NLS_("Integer")))) { if (attr == (NLS_("DOORS ID"))) old_pos = i insertAlphabetically_(linkSrcAttributeList, i++, attr) } } } insertAlphabetically_(linkSrcAttributeList, i++, (NLS_("Object Identifier"))) insertAlphabetically_(linkSrcAttributeList, i++, (NLS_("Object Number"))) set(linkSrcAttributeList, old_pos) }//End linkRefreshSrcAttributeList /******************************************************************************* * linkRefreshTgtAttributeListCB * */ void linkRefreshTgtAttributeListCB(Skip& Skp) { string attr = null int i = 0 int old_pos = (get (linkTgtAttributeList)) empty(linkTgtAttributeList) for attr in Skp do { if (attr == (NLS_("Object Identifier"))) { old_pos = i } insertAlphabetically_(linkTgtAttributeList, i++, attr) } set(linkTgtAttributeList, old_pos) }//End linkRefreshTgtAttributeListCB /******************************************************************************* * linkRefreshTgtAttributeList * */ void linkRefreshTgtAttributeList(Skip& skp) { int max = noElems(selectedTargetMods) int index = 0 string err = null if (max == 0) { empty(linkTgtAttributeList) return } for index in 0:max-1 do { string mname = (get (selectedTargetMods, index)) ModuleProperties mp ModuleVersion mv = moduleVersion(module mname) Skip temp = createString AttrDef ad = null string attr = null if (max <= 1) { setempty(skp) } noError() err = getProperties (mv, mp) if (!null err) warningBox(err) err = lastError() if (!null err){ errorBox(err) return } AddItemTrc = ((max > 1)?(true):(false)) for ad in mp do { if (null ad) continue if (ad.object) { if ((ad.typeName == (NLS_("Text"))) or (ad.typeName == (NLS_("String"))) or (ad.typeName == (NLS_("Integer")))) { attr = ad.name if (AddItemTrc) { put(temp, attr, attr) } else { put(skp, attr, attr) } } } } if (AddItemTrc) { for attr in skp do { if (!find(temp, attr)) { delete(skp, attr) } } } delete mv delete temp put(skp, (NLS_("Object Identifier")), (NLS_("Object Identifier"))) put(skp, (NLS_("Object Number")), (NLS_("Object Number"))) } linkRefreshTgtAttributeListCB(skp) }//End linkRefreshTgtAttributeList /******************************************************************************* * linkCheckSelection * */ Module linkCheckSelection(string trg_name, link_name, attr_name, key_name, string link_dir) { Module result = null string err = null if (null attr_name) { ack (NLS_("No attribute is specified")) return result } if (null trg_name) { ack (NLS_("No target module is selected")) return result } if (null key_name) { ack (NLS_("No key attribute is specified")) return result } if (null link_name) { ack (NLS_("No link module is selected")) return result } if (isRead linkSrcMod) { ack (NLS_("The source module '")) name(linkSrcMod) (NLS_("' must be open editable")) return result } if (!exists module link_name) { ack (NLS_("The link module '")) link_name (NLS_("' does not exist any more")) return result } if (!exists module trg_name) { ack (NLS_("The target module '")) trg_name (NLS_("' does not exist any more")) return result } if (link_dir == linkLinkTrgToSrc || link_dir == linkLinkBothWays) { noError() result = edit(trg_name, true, false, true) err = lastError() if (!null err) errorBox(err) } else { noError() result = read(trg_name, false, true) err = lastError() if (!null err) errorBox(err) } if (null result) { ack (NLS_("Failed to open the target module '")) trg_name (NLS_("'")) return result } return result }//End linkCheckSelection /******************************************************************************* * linkSelectionMade * */ void linkSelectionMade(DBE lstv, int sel) { } // linkSelectionMade /******************************************************************************* * linkDeselection * */ void linkDeselection(DBE lstv, int sel) { } // linkDeselection /******************************************************************************* * listActivate * */ void listActivate (DBE win, int sel) { glbsel = sel string LINKMODULE = getColumnValue(selectedTargetMods, sel, 1) string DIRECTION = getColumnValue(selectedTargetMods, sel, 2) if (DIRECTION == (NLS_("Source to target"))) { set(directionRadioBox, 0) } else if (DIRECTION == (NLS_("Target to source"))) { set(directionRadioBox, 1) } else { set(directionRadioBox, 2) } set(linkModField, LINKMODULE) block editDB inactive(okButton) raise(LinkDB) }//End listActivate. /******************************************************************************* * treeSelect * */ void treeSelect (DBE win) { }//End treeSelect /******************************************************************************* * treeActivate * */ void treeActivate (DBE win) { Buffer temp = create (1) bool itemSelected = false temp = (NLS_("/")) temp += (get (win)) Item I = item (tempStringOf (temp)) if (type (I) == (NLS_("Formal"))) { //Make sure the module hasn't been selected all ready. for (i = 0; i < numItems; i++) { if (tempStringOf (temp) == (get (selectedTargetMods, i))) { itemSelected = true break } } if (!itemSelected) { //Enter the module in the Target Modules list. insert (selectedTargetMods, numItems, tempStringOf (temp), iconFormal) linkRefreshTgtAttributeList(linkTgtAttributeSkip) set(linkModField, "") //clear glbsel = numItems block editDB inactive(okButton) numItems++ } else { //Let the user know the module was all ready selected. ack ((NLS_("Module has all ready been selected."))) } } delete (temp) }//End treeActivate. /******************************************************************************* * linkNextValue * */ string linkNextValue(string &s) { string result = (NLS_("")) Regexp hasField = regexp (NLS_("[ ,;\t\n]*([^,;\t\n]+)[ ,;\t\n]*")) while ((null result) and (! null s)) { hasField s result = s[match 1] s = s[end(0)+1:] } delete hasField return result }//End linkNextValue /******************************************************************************* * toggleButton * */ void toggleButton (DBE win) { string link_name = getColumnValue(selectedTargetMods, glbsel, 1) if(!null link_name) { active(okButton) } }//End toggleButton /******************************************************************************* * linkFindObjects * */ void linkFindObjects(string value, Module m, string key_name, Skip objectList) { Object o = null string key = null for o in entire m do { if (null o) continue if (isDeleted(o)) continue if (key_name == (NLS_("Object Identifier"))) { key = identifier(o) } else if (key_name == (NLS_("Object Number"))) { key = number(o) } else { key = probeAttr_(o, key_name) } if (key == value) { put(objectList, o, o) } } }//End linkFindObjects /******************************************************************************* * linkCreateLink * */ bool LinkPairing (string srcModName, string linkModName, string targetModName) { string errmsg = null if ((!null linkModName) && (!null srcModName) && (!null targetModName)) { //Get the source module's parent folder. Folder fol = getParentFolder((module(item(srcModName)))) //Create the link module descriptor in the source module. errmsg = addLinkModuleDescriptor(fol, srcModName, targetModName, false, true, linkModName, "") if ((!null errmsg) && (errmsg != (NLS_("Source/target pairing already present")))) { errorBox(errmsg) } else { //Set "only outgoing links as specified in the above list" setLinkModuleDescriptorsExclusive(fol, module(srcModName), true) return(true) } } return(false) }//End createLinksSets. /******************************************************************************* * linkCreateLink * */ bool linkCreateLink(Object src_obj, trg_obj, string link_name, string link_dir) { int link_err = linkErrorNoError bool links_created = false if (link_dir == linkLinkSrcToTrg || link_dir == linkLinkBothWays) { if (LinkPairing(fullName(module(src_obj)), link_name, fullName(module(trg_obj)))) { link_err = createLink_(src_obj, link_name, trg_obj) reportLinkError_(src_obj, trg_obj, link_name, (NLS_("source")), link_err) if (link_err == linkErrorNoError) { links_created = true } } else { errorBox((NLS_("Unable to create LinkParing ")) fullName(module(src_obj)) (NLS_(" -> ")) fullName(module(trg_obj))) } } if (link_dir == linkLinkTrgToSrc || link_dir == linkLinkBothWays) { if (LinkPairing(fullName(module(trg_obj)), link_name, fullName(module(src_obj)))) { link_err = createLink_(trg_obj, link_name, src_obj) reportLinkError_(trg_obj, src_obj, link_name, (NLS_("target")), link_err) if (link_err == linkErrorNoError) { links_created = true } } else { errorBox((NLS_("Unable to create LinkParing ")) fullName(module(src_obj)) (NLS_(" -> ")) fullName(module(trg_obj))) } } return links_created }//End linkCreateLink /******************************************************************************* * numObjs * */ int numObjs(Module m, Module trg_mod, string attr_name) { int n = 0 Object o = null string value, values for o in m do { if (null o) continue if (isDeleted(o)) continue values = probeAttr_(o, attr_name) if (attr_name == (NLS_("DOORS ID")) && !matches(("^"probeAttr_(trg_mod, "Prefix")".*"), values)) continue while (!null values) { value = linkNextValue(values) if (!null value) { if (attr_name == (NLS_("DOORS ID")) && !matches(("^"probeAttr_(trg_mod, "Prefix")".*"), value)) continue n++ } } } return(n) }//End numObjs /******************************************************************************* * compileNonTrace * */ string compileNonTrace(Object o) { Link l = null ModName_ otherMod = null Object othero = null Buffer s = create(); s = "" string value = null string err = null for l in all(o->"*") do { ModuleVersion otherVersion = targetVersion l otherMod = module(otherVersion) if (null otherMod || isDeleted otherMod) {delete otherVersion; continue} othero = target l if (null othero) { noError() read(fullName(otherVersion),false, true) err = lastError() if (!null err) errorBox(err) } othero = target l if (null othero) {delete otherVersion; continue} if (isDeleted othero) {delete otherVersion; continue} s += identifier(othero) s += (NLS_("\n")) delete otherVersion } value = stringOf(s) delete s return value }//End compileNonTrace /******************************************************************************* * errorLog * */ void errorLog(Module src_mod, string attr_name, string key_name) { Object o = null Buffer temp = create; temp = "" string value = null string values = null if (glbprogressCancelled) { noError() initNotDisplayedOpenModules() //memory management lastError() if (attr_name == (NLS_("DOORS ID")) && key_name == (NLS_("Object Identifier"))) { for o in entire src_mod do { if (null o) continue if (isDeleted(o)) continue values = probeAttr_(o, attr_name) if(!matches("[0-9]|[a-zA-Z]", values)) continue while (!null values) { value = linkNextValue(values) if (!null value) { Regexp line = regexp2 (NLS_(".*"value".*")) if (!line compileNonTrace(o)) { temp += (NLS_("Unable to find key('")) temp += value temp += (NLS_("') on Object('")) temp += probeAttr_(o, "Absolute Number") temp += (NLS_("')!\n")) } delete line } } } if (length(temp) > 0) { LogFile(fullName(src_mod)) LogFile(tempStringOf temp) } } noError() closeNotDisplayedOpenedModules() //memory management lastError() } delete temp }//End errorLog /******************************************************************************* * linkCreateLinks * */ void linkCreateLinks(Module src_mod, Module trg_mod, string trg_name, string link_name, string attr_name, string key_name, string link_dir) { Object o, trg_obj string values, value, err int link_err Buffer keysNotFound = create(); keysNotFound = "" bool sameKeysWithinModule Skip destnObjects = create() current = src_mod if (!exists attribute attr_name && attr_name != (NLS_("Object Identifier")) && attr_name != (NLS_("Object Number"))) { ack (NLS_("The specified attribute '")) attr_name (NLS_("' does not exist")) return } // Check for special case of linking between same keys fields within a module sameKeysWithinModule = ((src_mod == trg_mod) and (attr_name == key_name)) allowLinkErrors_ progressStart(LinkDB, (NLS_("Creating links from key attribute")), (NLS_("Indexing objects...")), numObjs(src_mod, trg_mod, attr_name)) progressMessage((NLS_("Creating links('")) name(trg_mod) (NLS_("')..."))) int n = 0 for o in entire src_mod do { if (null o) continue if (isDeleted(o)) continue if (progressCancelled()) { glbprogressCancelled = false break } // skip object if already linked to in special case if (sameKeysWithinModule and (find (destnObjects, o))) continue current = linkSrcMod if (attr_name == (NLS_("Object Identifier"))) { values = identifier(o) } else if (attr_name == (NLS_("Object Number"))) { values = number(o) } else { values = probeAttr_(o, attr_name) } if (attr_name == (NLS_("DOORS ID")) && !matches(("^"probeAttr_(trg_mod, "Prefix")".*"), values)) continue while (!null values) { value = linkNextValue(values) if (!null value) { if (attr_name == (NLS_("DOORS ID")) && !matches(("^"probeAttr_(trg_mod, "Prefix")".*"), value)) continue Skip matchingObjects = create() int numMatchingObjects = 0 linkFindObjects (value, trg_mod, key_name, matchingObjects) for trg_obj in matchingObjects do { // don't create recursive links if (trg_obj == o) continue if (linkCreateLink(o, trg_obj, link_name, link_dir)) { if (sameKeysWithinModule) put (destnObjects, trg_obj, trg_obj) numMatchingObjects ++ } } progressStep(n++) if (numMatchingObjects == 0) { keysNotFound += (NLS_("Unable to find key('")) value (NLS_("') on Object('")) probeAttr_(o, "Absolute Number") (NLS_("')!\n")) } delete matchingObjects } } } if (glbprogressCancelled) { progressMessage((NLS_("Saving links('")) name(trg_mod) (NLS_("')..."))) if (isEdit(src_mod)) { noError() save(src_mod) err = lastError() if (!null err) errorBox(err) } if (isEdit(trg_mod)) { noError() save(trg_mod) err = lastError() if (!null err) errorBox(err) } if (attr_name != (NLS_("DOORS ID")) && key_name != (NLS_("Object Identifier"))) { if (length(keysNotFound) > 0) { LogFile(fullName(trg_mod)) LogFile(tempStringOf keysNotFound) } } } progressStop() delete keysNotFound delete destnObjects noError() close(trg_mod) err = lastError() if (!null err) errorBox(err) } //End linkCreateLinks /******************************************************************************* * linkCreateLinksCB * */ void linkCreateLinksCB(void) { Module trg_mod = null string attr_name = (get (linkSrcAttributeList)) string trg_name = null string key_name = (get (linkTgtAttributeList)) string link_name = null string link_dir = null int max = noElems(selectedTargetMods) if (max == 0) return for index in 0:max-1 do { if (glbprogressCancelled) { noError() initNotDisplayedOpenModules() //memory management lastError() trg_name = getColumnValue(selectedTargetMods, index, 0) link_name = getColumnValue(selectedTargetMods, index, 1) link_dir = getColumnValue(selectedTargetMods, index, 2) trg_mod = linkCheckSelection(trg_name, link_name, attr_name, key_name, link_dir) if (null trg_mod) return linkCreateLinks(linkSrcMod, trg_mod, trg_name, link_name, attr_name, key_name, link_dir) noError() closeNotDisplayedOpenedModules() //memory management lastError() } } errorLog(linkSrcMod, attr_name, key_name) }//End linkCreateLinksCB /******************************************************************************* * validationCheck * */ void validationCheck (DB win) { if (fileExists_(fName)) { results = deleteFile(fName) if (!null results) { errorBox(results) hide (LinkDB) release (LinkDB) } } glbprogressCancelled = true TimeStart = getTickCount_() string attr_name = (get (linkSrcAttributeList)) string key_name = (get (linkTgtAttributeList)) if (null attr_name) { ack (NLS_("No attribute is specified")) return } else if (null key_name) { ack (NLS_("No key attribute is specified")) return } else if (numItems > 0) { linkCreateLinksCB() //Only show if log was written to if (fileExists_(fName)) { win32SystemWait_((NLS_("notepad.exe \""fName"\"")), results, 0) if (!null results) errorBox((NLS_("Err:{notepad.exe \"")) fName (NLS_("\" '")) results (NLS_("'}"))) } else { hide (LinkDB) release (LinkDB) } TimeEnd = getTickCount_() infoBox(timer(TimeEnd - TimeStart)) } else { ack (NLS_("You must select at least one target module.")) } }//End validationCheck. /******************************************************************************* * linkPathCB * */ void linkPathCB (DBE) { Item i = item fnMiniExplorer(editDB, MINI_EXP_LINK_MODS, null, null) if (!null i && type (i) == (NLS_("Link"))) { active(okButton) set(linkModField, (fullName(i) "")) } else { inactive(okButton) warningBox((NLS_("{Null/Invalid} entry!"))) } }//End linkPathCB /******************************************************************************* * doUpdate * */ void doUpdate(DB x) { string LINKMODULE = (get (linkModField)) int choice = (get (directionRadioBox)) string DIRECTION = (direction[choice]) set(selectedTargetMods, glbsel, 1, LINKMODULE) set(selectedTargetMods, glbsel, 2, DIRECTION) hide (editDB) inactive(okButton) release (editDB) }//End doUpdate /******************************************************************************* * closeCallback * */ void closeCallback (DB win) { hide (LinkDB) release (LinkDB) }//End closeCallback. /******************************************************************************* * closeEditCallback * */ void closeEditCallback(DB x) { string trg_name = getColumnValue(selectedTargetMods, glbsel, 0) string link_name = getColumnValue(selectedTargetMods, glbsel, 1) string link_dir = getColumnValue(selectedTargetMods, glbsel, 2) if (null trg_name || null link_name || null link_dir) { //Delete the item from the list. delete (selectedTargetMods, glbsel) numItems-- } hide(editDB) inactive(okButton) release(editDB) }//End closeEditCallback /******************************************************************************* * removeCallback * */ void removeCallback(DB x) { //Delete the item from the list. delete (selectedTargetMods, glbsel) numItems-- hide(editDB) inactive(okButton) release(editDB) }//End removeCallback /******************************************************************************* * doSortString * */ int doSortString(string s1, string s2) { return(cistrcmp(s1, s2)) }//End doSortString /******************************************************************************* * LookUpTableValidation * */ void LookUpTableValidation(string strKey) { Skip LookUpLM = createString //Lookup for LinkModule based on Target 'Prefix' Skip LookUpFM = createString //Lookup for Target based on Target 'Prefix' put(LookUpLM, "IIIP - ", "???") put(LookUpFM, "IIIP - ", "???") string LM = null string FM = null if (find(LookUpLM, strKey, LM) && find(LookUpFM, strKey, FM)) { Item LMitm = item LM Item FMitm = item FM if (null LMitm || null FMitm) { errorBox("Key {'"strKey"'} Null") } else if (isDeleted LMitm || isDeleted FMitm) { warningBox("Key {'"strKey"'} isDeleted") } else { //Enter the module in the Target Modules list. insert (selectedTargetMods, glbsel, fullName(FMitm), iconFormal) linkRefreshTgtAttributeList(linkTgtAttributeSkip) set(selectedTargetMods, glbsel, 1, fullName(LMitm)) set(selectedTargetMods, glbsel, 2, (string (direction[0]))) glbsel = numItems numItems++ } } else { warningBox("Key {'"strKey"'} !Found") } delete LookUpLM delete LookUpFM }//End LookUpTableValidation /******************************************************************************* * TrimValue * */ string TrimValue(string &s) { string result = (NLS_("")) Regexp hasField = regexp (NLS_("(([A-Za-z]+)* +- +)")) if(hasField s) { result = s[match 0] } delete hasField return result }//End TrimValue /******************************************************************************* * findKeys * */ void findKeys(Module src_mod, string attr_name, Skip& SkpKeys) { Object o = null string values = null string value = null for o in entire src_mod do { if (null o) continue if (isDeleted(o)) continue values = probeAttr_(o, attr_name) if(!matches("[0-9]|[a-zA-Z]", values)) continue while (!null values) { value = linkNextValue(values) value = TrimValue(value) if (!null value) { put(SkpKeys, value, value, true) } } } }//End findKeys /******************************************************************************* * createDB * */ void createDB () { //Get the currently selected item in the DOORS Explorer. Item I = null if (null current Module) { I = getSelectedItem () } else { I = item(fullName(current Module)) } ModName_ mn = module(fullName (I)) /********************************************************************* * Create the DB if the selected item meets the following conditions: * * - Item is a formal module. * * - The user has the rights to modify the module. * * - The module is not locked by another user. * *********************************************************************/ if (!isDeleted (I) && type (I) == (NLS_("Formal")) && canModify (I) && (!isLocked (mn) || (isLocked (mn) && open (mn)))) { noError() linkSrcMod = edit(fullName (I), true, false, true) string err = lastError() if (!null err) { errorBox(err) } else { Project p = getParentProject (I) LinkDB = create (linkSrcMod, (NLS_("Link By Key Attribute v4.8")), styleSubWindow|styleCentered) editDB = create("Edit Links/LinkSets...", styleCentered) sourceMod = field (LinkDB, (NLS_("Source Module:")), fullName (I), 75, true) linkSrcAttributeList = list(LinkDB, (NLS_("Source reference attribute:")), 5, dummy_list) linkTgtAttributeList = list(LinkDB, (NLS_("Target reference attribute:")), 5, dummy_list) frame1 = frame (LinkDB, (NLS_("Select Target Modules:")), 350, 250) frame2 = frame (LinkDB, (NLS_("Selected Target Modules:")), 500, 250) selectTargetMods = treeView (LinkDB, treeViewOptionSorted, 250, 10) selectedTargetMods = listView(LinkDB, listViewOptionSortText, 230, 10, items) set(selectedTargetMods, linkSelectionMade, linkDeselection, listActivate) set (selectTargetMods, treeSelect, treeActivate) //Place the DBE's. sourceMod->"left"->"form" frame1->"right"->"unattached" frame1->"bottom"->"form" frame2->"top"->"aligned"->frame1 frame2->"left"->"spaced"->frame1 frame2->"bottom"->"form" selectTargetMods->"left"->"inside"->frame1 selectTargetMods->"top"->"inside"->frame1 selectTargetMods->"right"->"inside"->frame1 selectTargetMods->"bottom"->"inside"->frame1 selectedTargetMods->"left"->"inside"->frame2 selectedTargetMods->"top"->"inside"->frame2 selectedTargetMods->"right"->"inside"->frame2 selectedTargetMods->"bottom"->"inside"->frame2 linkSrcAttributeList linkTgtAttributeList apply (LinkDB, (NLS_("OK")), validationCheck) close (LinkDB, true, closeCallback) //editDB linkModField = field(editDB, "Link module:", "", 30, true) linkModField -> "top" -> "form"; linkModField -> "left" -> "form"; linkModField -> "right" -> "unattached"; linkModField -> "bottom" -> "unattached" linkBrowseButton = button(editDB, "Browse...", linkPathCB) linkBrowseButton -> "top" -> "aligned" -> linkModField; linkBrowseButton -> "left" -> "flush" -> linkModField; linkBrowseButton -> "right" -> "unattached"; linkBrowseButton -> "bottom" -> "unattached" directionRadioBox = radioBox(editDB, "", direction, 0) directionRadioBox -> "top" -> "flush" -> linkBrowseButton; directionRadioBox -> "left" -> "form"; directionRadioBox -> "right" -> "unattached"; directionRadioBox -> "bottom" -> "form" set(directionRadioBox, toggleButton) close (editDB, true, closeEditCallback) rmButton = ok(editDB, (NLS_("Remove")), removeCallback) okButton = ok(editDB, (NLS_("OK")), doUpdate); inactive(okButton) //End editDB realize (LinkDB) insertColumn(selectedTargetMods, 0, "Target module", 210, iconNone); set(selectedTargetMods, 0, doSortString) // Allow sorting this column insertColumn(selectedTargetMods, 1, "LinkMoule", 210, iconNone); set(selectedTargetMods, 1, doSortString) // Allow sorting this column insertColumn(selectedTargetMods, 2, "Direction", 110, iconNone); set(selectedTargetMods, 2, doSortString) // Allow sorting this column linkRefreshSrcAttributeList(linkSrcMod) insert (selectTargetMods, fullName (p), iconProject, iconProjectOpen) //Populate the treeView with the folders and modules within the current project. for I in p do { if (null I) continue if (isDeleted (I)) continue if (type (I) == (NLS_("Folder"))) { insert (selectTargetMods, fullName (I), iconFolder, iconFolderOpen) } else if (type (I) == (NLS_("Formal"))) { insert (selectTargetMods, fullName (I), iconFormal, iconFormal) } } //Automatic configuration Skip temp = createString string strKey = null findKeys(linkSrcMod, "DOORS ID", temp) for strKey in temp do { LookUpTableValidation(strKey) } delete temp //End of Automatic configuration block(LinkDB) destroy (LinkDB) LinkDB = null destroy (editDB) editDB = null } } else { //Warning message if the item is deleted. if (isDeleted (I)) { ack (NLS_("The item selected is deleted.")) } //Warning message if the selected item is not a formal module. else if (type (I) != (NLS_("Formal"))) { ack (NLS_("You must select a formal module.")) } //Warning message if the user does not have permissions to modify the module. else if (!canModify (I)) { ack (NLS_("You do not have permissions to create link sets in this module.")) } //Warning message if the module is locked by another user. else if (isLocked (mn) || (!isLocked (mn) && !open (mn))) { //Get the locklist for the module. LockList ls = getLocksInModule (mn, true) Lock lck string temp User usr //Find the user the that has the lock on the module for lck in ls do { if (null lck) continue //Get the user name. temp = lck.user //Find the user. usr = find (temp) //If the name attribute is set on the user, then use it //otherwise just use the user name. if (usr.name != null) { temp = usr.name } } delete ls ack (NLS_(temp " currently has a lock on this module.")) } } }//End createDB. ///---------------------------------------------------------------------------------- PrintAllocs((NLS_("Allocated Objects at Start(createDB) of DXL code:"))) ///---------------------------------------------------------------------------------- createDB () ///---------------------------------------------------------------------------------- PrintAllocs((NLS_("Allocated Objects at End(createDB) of DXL code:"))) ///---------------------------------------------------------------------------------- delete linkSrcAttributeSkip delete linkTgtAttributeSkip ///---------------------------------------------------------------------------------- PrintAllocs((NLS_("Allocated Objects at End(Script) of DXL code:"))) ///----------------------------------------------------------------------------------